<?php
namespace MyBase;
use Think\Controller;
class BaseController extends Controller {
	protected $carNum = null;
	public function __construct(){
		parent::__construct();
		$carData = cookie('myCar');
		if(!isset($carData)){
			$this->carNum = 0;
		}else{
			$this->carNum = count(unserialize(cookie('myCar')));
		}
	}
	/**
	 * [验证码]
	 */
	public function verify(){
		$config =    array(    
			'fontSize'    =>    30,    // 验证码字体大小    
			'length'      =>    4,     // 验证码位数    
			'useNoise'    =>    false, // 关闭验证码杂点
			'useCurve'	  =>	false,  //关闭曲线
			'fontttf'	  =>    '5.ttf',
		);
		$Verify = new \Think\Verify($config);
		$Verify->entry();		
	}

	//自定义打印的方法
	public function P($v,$printType='p'){
		echo "<pre>";
		if($printType == 'p'){
			print_r($v);
		}else{
			var_dump($v);
		}
		exit;
	}

	public function ajaxReturn($status,$message=null,$data=null){
		$dataReturn = array(
			'status'	=>	$status,
			'message'	=>	$message,
			'data'		=>	$data,
			);
		return parent::ajaxReturn($dataReturn);
	}
	public function __get($ModelName){
		$Model = '\\MyModel\\'.$ModelName;
		$M = new $Model();
		return $M;
	}
}